These samples show how to load an XML document and run queries against it.

public void XLinq5()
{
XmlReader reader = XmlReader.Create("config.xml");
//the file has comments and whitespace at the start
reader.Read();
reader.Read();
XElement config = new XElement("appSettings",
"This content will be replaced");
config.RemoveAll();
while (!reader.EOF)
config.Add(XNode.ReadFrom(reader));
Console.WriteLine(config);
}
public void XLinq5() { XmlReader reader = XmlReader.Create("config.xml"); //the file has comments and whitespace at the start reader.Read(); reader.Read(); XElement config = new XElement("appSettings", "This content will be replaced"); config.RemoveAll(); while (!reader.EOF) config.Add(XNode.ReadFrom(reader)); Console.WriteLine(config); }
For more information on LINQ to XML: http://msdn.microsoft.com/en-us/library/bb387098.aspx